cmake_minimum_required(VERSION 3.16.0)

#set(PICO_BOARD pico2)   
#set(PICO_PLATFORM rp2350-arm-s)   
#set(PICO_PLATFORM rp2040)  


# Pull in SDK (must be before project)
include(pico_sdk_import.cmake) 

project(pico_infones C CXX ASM) 

# Initialize the SDK
pico_sdk_init()

# Set all global variables here
#set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Wl,--print-memory-usage")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Wl,--print-memory-usage")



include_directories(./)
include_directories(driver)
#include_directories(lvgl)
#include_directories(lvgl/demos)
#include_directories(lvgl/examples/porting)

add_executable(pico_infones)

#pico_generate_pio_header(RPi_pico_100ask_infones ${CMAKE_CURRENT_LIST_DIR}/ili9341_lcd.pio)

target_sources(pico_infones PRIVATE 
	 pico_infones.c   
     #nespad320x240.c  
     driver/ili9488.c
     driver/ft6236.c
     driver/i2c_tools.c
     driver/backlight.c 
                 )

                 
# LCD Pins for 8080 interface
set(LCD_PIN_DB_BASE  0)  # 8080 LCD data bus base pin
set(LCD_PIN_DB_COUNT 16) # 8080 LCD data bus pin count
set(LCD_PIN_CS  18)  # 8080 LCD chip select pin
set(LCD_PIN_WR  19)  # 8080 LCD write pin
set(LCD_PIN_RS  20)  # 8080 LCD register select pin
set(LCD_PIN_RST 22)  # 8080 LCD reset pin
set(LCD_PIN_BL  28)  # 8080 LCD backlight pin
set(DISP_OVER_PIO 1) # 1: PIO, 0: GPIO
				 

target_compile_definitions(${PROJECT_NAME} PUBLIC LCD_PIN_DB_BASE=${LCD_PIN_DB_BASE})
target_compile_definitions(${PROJECT_NAME} PUBLIC LCD_PIN_DB_COUNT=${LCD_PIN_DB_COUNT})
target_compile_definitions(${PROJECT_NAME} PUBLIC LCD_PIN_CS=${LCD_PIN_CS})
target_compile_definitions(${PROJECT_NAME} PUBLIC LCD_PIN_WR=${LCD_PIN_WR})
target_compile_definitions(${PROJECT_NAME} PUBLIC LCD_PIN_RS=${LCD_PIN_RS})
target_compile_definitions(${PROJECT_NAME} PUBLIC LCD_PIN_RST=${LCD_PIN_RST})
target_compile_definitions(${PROJECT_NAME} PUBLIC LCD_PIN_BL=${LCD_PIN_BL})
target_compile_definitions(${PROJECT_NAME} PUBLIC DISP_OVER_PIO=${DISP_OVER_PIO})




add_subdirectory(pio)
add_subdirectory(infones) 
#add_subdirectory(lvgl)


# lv_conf.h need pico header files e.g. the custom tick
#target_link_libraries(lvgl PRIVATE pico_stdlib)

# Pull in our (to be renamed) simple get you started dependencies
target_link_libraries(pico_infones  
    infones
    #lvgl 
    #lvgl::demos lvgl::examples 
    hardware_pwm 
     hardware_i2c 
     pico_multicore
      hardware_pio 
      hardware_interp 
      hardware_spi 
      hardware_clocks 
      hardware_adc 
      pio_i80       
      pico_stdlib
      )

      #target_compile_definitions(lvgl PUBLIC LV_CONF_PATH=${CMAKE_CURRENT_SOURCE_DIR}/lvgl/lvgl.h)

# create map/bin/hex file etc.
pico_add_extra_outputs(pico_infones)

# add url via pico_set_program_url
#example_auto_set_url((pico_infones)

